<%
# We have to remove search form params before the url_for method call, otherwise it throughs it on
search_params = params[:search]
params.merge!(:search => nil)
href = url_for(params_for(:action => :update_table, :escape => false).delete_if{|k,v| k == 'search'})
-%>
<%= form_tag href,
             :method => :post,
             :id => "searchForm",
             :class => 'dialog search'
%>
  <fieldset>
    <h1>Search</h1>
    <%= link_to as_('Cancel'), {}, :type => "cancel", :class => "dialogButton leftButton submit" %>
    <%= link_to as_('Search'), {}, :type => "submit", :class => "dialogButton blueButton submit" %>
    <% active_scaffold_config.field_search.columns.each do |column| -%>
      <% name = "search[#{column.name}]" %>
      <% value = nil %>
      <% value = search_params[column.name] if search_params %>
        <label for="<%= "search_#{column.name}" %>"><%= column.label %></label>
        <%= case column.column.type
          when :boolean
            options = [
              ['', ''],
              [as_('True'), 1],
              [as_('False'), 0]
            ]
            select_tag name, options_for_select(options, value)
          else
            text_field_tag(name, value, { :autocomplete => "off", :size => 20, :class => 'text-input', :id => "search_#{column.name}"})
          end
        %>
    <% end -%>
  </fieldset>
</form>
